home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
cmln0985.arc
/
PARSER.BAS
< prev
next >
Wrap
BASIC Source File
|
1986-02-27
|
1KB
|
19 lines
1000 ' ===================A TINY BASIC PARSER==============================
1010 ' (technically, a "finite automaton" accepter for regular expressions)
1020 '
1030 ' Direct comments, questions, abuse to:
1040 ' David Ross, Dept. of Math., Univ. of Iowa, Iowa City, IA 52242
1050 '
1060 ' See PARSER.DOC for a more complete explanation of this program
1070 '
1080 ' Routine assumes that arrays NN$, ND, and CD$ are defined already
1090 '
1100 CN=0:OUTSTR$="" 'Start at node 0; init. output string
1110 L=LEN(NN$(CN)):IF L=0 THEN RETURN 'If CurrentNode is terminal, quit
1120 CH$=INPUT$(1):I=0 'Read a ch$; init. "NextNode" pointer
1130 I=I+1: IF I>L THEN 1120 'Tried all NextNodes? Then ignore ch$
1140 IF INSTR(CD$(ND(ASC(MID$(NN$(CN),I)))),CH$)=0 THEN 1130
1150 ' Is ch$ in the "acceptable" list for NextNode # I ? If not, try I+1
1160 OUTSTR$=OUTSTR$+CH$:PRINT CH$; ' *Is* on I's list; accept ch$...
1170 CN=ASC(MID$(NN$(CN),I)):GOTO 1110 ' ...and make NextNode CurrentNode
$+CH$:PRINT CH$;